<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
 <head>
  <meta http-equiv="content-type" content="text/html; charset=UTF-8">
  <title>The EvPrepare class</title>

 </head>
 <body><div class="manualnavbar" style="text-align: center;">
 <div class="prev" style="text-align: left; float: left;"><a href="evperiodic.set.html">EvPeriodic::set</a></div>
 <div class="next" style="text-align: right; float: right;"><a href="evprepare.construct.html">EvPrepare::__construct</a></div>
 <div class="up"><a href="book.ev.html">Ev</a></div>
 <div class="home"><a href="index.html">PHP Manual</a></div>
</div><hr /><div id="class.evprepare" class="reference">
 <h1 class="title">The EvPrepare class</h1>
 
 <div class="partintro"><p class="verinfo">(PECL ev &gt;= 0.2.0)</p>

  <div class="section" id="evprepare.intro">
   <h2 class="title">简介</h2><p class="para">
    <strong class="classname">EvPrepare</strong>
    and
    <a href="class.evcheck.html" class="classname">EvCheck</a>
    watchers are usually used in pairs.
    <strong class="classname">EvPrepare</strong>
    watchers get invoked before the process blocks,
    <a href="class.evcheck.html" class="classname">EvCheck</a>
    afterwards.
   </p><p class="para">
    It is not allowed to call
    <span class="methodname"><a href="evloop.run.html" class="methodname">EvLoop::run()</a></span>
    or similar methods or functions that enter the current event loop from
    either
    <strong class="classname">EvPrepare</strong>
    or
    <a href="class.evcheck.html" class="classname">EvCheck</a>
    watchers. Other loops than the current one are fine, however. The
    rationale behind this is that one don&#039;t need to check for recursion
    in those watchers, i.e. the sequence will always be:
    <strong class="classname">EvPrepare</strong>
    -&gt; blocking -&gt;
    <a href="class.evcheck.html" class="classname">EvCheck</a>
    , so having a watcher of each kind they will always be called in pairs
    bracketing the blocking call.
   </p><p class="para">
    The main purpose is to integrate other event mechanisms into
    <em class="emphasis">libev</em>
    and their use is somewhat advanced. They could be used, for example, to
    track variable changes, implement custom watchers, integrate net-snmp or a
    coroutine library and lots more. They are also occasionally useful to
    cache some data and want to flush it before blocking.
   </p><p class="para">
    It is recommended to give
    <a href="class.evcheck.html" class="classname">EvCheck</a>
    watchers highest(
    <strong><code>Ev::MAXPRI</code></strong>
    ) priority, to ensure that they are being run before any other watchers
    after the poll (this doesn’t matter for
    <strong class="classname">EvPrepare</strong>
    watchers).
   </p><p class="para">
    Also,
    <a href="class.evcheck.html" class="classname">EvCheck</a>
    watchers should not activate/feed events. While
    <em class="emphasis">libev</em>
    fully supports this, they might get executed before other
    <a href="class.evcheck.html" class="classname">EvCheck</a>
    watchers did their job.
   </p>
  </div>

  <div class="section" id="evprepare.synopsis">
   <h2 class="title">类摘要</h2>


   <div class="classsynopsis">
    <div class="ooclass">
     
    </div>

    <div class="classsynopsisinfo">
     <span class="ooclass">
      <strong class="classname">EvPrepare</strong>
     </span>
     <span class="ooclass">
      <span class="modifier">extends</span>
      <a href="class.evwatcher.html" class="classname">EvWatcher</a>
     </span>
     {</div>


    <div class="classsynopsisinfo classsynopsisinfo_comment">/* 继承的属性 */</div>
    <div class="fieldsynopsis">
     <span class="modifier">public</span>
      <var class="varname"><a href="class.evwatcher.html#evwatcher.props.is-active">$<var class="varname">is_active</var></a></var>
    ;</div>
<div class="fieldsynopsis">
     <span class="modifier">public</span>
      <var class="varname"><a href="class.evwatcher.html#evwatcher.props.data">$<var class="varname">data</var></a></var>
    ;</div>
<div class="fieldsynopsis">
     <span class="modifier">public</span>
      <var class="varname"><a href="class.evwatcher.html#evwatcher.props.is-pending">$<var class="varname">is_pending</var></a></var>
    ;</div>
<div class="fieldsynopsis">
     <span class="modifier">public</span>
      <var class="varname"><a href="class.evwatcher.html#evwatcher.props.priority">$<var class="varname">priority</var></a></var>
    ;</div>

    <div class="classsynopsisinfo classsynopsisinfo_comment">/* 方法 */</div>
    <div class="methodsynopsis dc-description">
   <span class="modifier">public</span>
   <span class="methodname"><a href="evprepare.construct.html" class="methodname">__construct</a></span>
    ( <span class="methodparam">
    <span class="type">string</span>
     <code class="parameter">$callback</code>
   </span>
   [, <span class="methodparam">
    <span class="type">string</span>
     <code class="parameter">$data</code>
   </span>
   [, <span class="methodparam">
    <span class="type">string</span>
     <code class="parameter">$priority</code>
   </span>
  ]] )</div>
<div class="methodsynopsis dc-description">
   <span class="modifier">final</span>
   <span class="modifier">public</span>
   <span class="modifier">static</span>
   <span class="type">EvPrepare</span>
   <span class="methodname"><a href="evprepare.createstopped.html" class="methodname">createStopped</a></span>
    ( <span class="methodparam">
    <span class="type"><a href="language.types.callable.html" class="type callable">callable</a></span>
     <code class="parameter">$callback</code>
   </span>
   [, <span class="methodparam">
    <span class="type"><a href="language.pseudo-types.html#language.types.mixed" class="type mixed">mixed</a></span>
     <code class="parameter">$data</code>
    <span class="initializer"> = <strong><code>NULL</code></strong></span>
   </span>
   [, <span class="methodparam">
    <span class="type">int</span>
     <code class="parameter">$priority</code>
    <span class="initializer"> = 0</span>
   </span>
  ]] )</div>

    <div class="classsynopsisinfo classsynopsisinfo_comment">/* 继承的方法 */</div>
    <div class="methodsynopsis dc-description">
   <span class="modifier">public</span>
   <span class="type">int</span>
   <span class="methodname"><a href="evwatcher.clear.html" class="methodname">EvWatcher::clear</a></span>
    ( <span class="methodparam">void</span>
   )</div>
<div class="methodsynopsis dc-description">
   <span class="modifier">abstract</span>
   <span class="modifier">public</span>
   <span class="methodname"><a href="evwatcher.construct.html" class="methodname">EvWatcher::__construct</a></span>
    ( <span class="methodparam">void</span>
   )</div>
<div class="methodsynopsis dc-description">
   <span class="modifier">public</span>
   <span class="type">void</span>
   <span class="methodname"><a href="evwatcher.feed.html" class="methodname">EvWatcher::feed</a></span>
    ( <span class="methodparam">
    <span class="type">int</span>
     <code class="parameter">$revents</code>
   </span>
   )</div>
<div class="methodsynopsis dc-description">
   <span class="modifier">public</span>
   <span class="type">EvLoop</span>
   <span class="methodname"><a href="evwatcher.getloop.html" class="methodname">EvWatcher::getLoop</a></span>
    ( <span class="methodparam">void</span>
   )</div>
<div class="methodsynopsis dc-description">
   <span class="modifier">public</span>
   <span class="type">void</span>
   <span class="methodname"><a href="evwatcher.invoke.html" class="methodname">EvWatcher::invoke</a></span>
    ( <span class="methodparam">
    <span class="type">int</span>
     <code class="parameter">$revents</code>
   </span>
   )</div>
<div class="methodsynopsis dc-description">
   <span class="modifier">public</span>
   <span class="type">bool</span>
   <span class="methodname"><a href="evwatcher.keepalive.html" class="methodname">EvWatcher::keepalive</a></span>
    ([ <span class="methodparam">
    <span class="type">bool</span>
     <code class="parameter">$value</code>
   </span>
  ] )</div>
<div class="methodsynopsis dc-description">
   <span class="modifier">public</span>
   <span class="type">void</span>
   <span class="methodname"><a href="evwatcher.setcallback.html" class="methodname">EvWatcher::setCallback</a></span>
    ( <span class="methodparam">
    <span class="type"><a href="language.types.callable.html" class="type callable">callable</a></span>
     <code class="parameter">$callback</code>
   </span>
   )</div>
<div class="methodsynopsis dc-description">
   <span class="modifier">public</span>
   <span class="type">void</span>
   <span class="methodname"><a href="evwatcher.start.html" class="methodname">EvWatcher::start</a></span>
    ( <span class="methodparam">void</span>
   )</div>
<div class="methodsynopsis dc-description">
   <span class="modifier">public</span>
   <span class="type">void</span>
   <span class="methodname"><a href="evwatcher.stop.html" class="methodname">EvWatcher::stop</a></span>
    ( <span class="methodparam">void</span>
   )</div>

   }</div>

  </div>
 </div>

 











<h2>Table of Contents</h2><ul class="chunklist chunklist_reference"><li><a href="evprepare.construct.html">EvPrepare::__construct</a> — Constructs EvPrepare watcher object</li><li><a href="evprepare.createstopped.html">EvPrepare::createStopped</a> — Creates a stopped instance of EvPrepare watcher</li></ul>
</div>
<hr /><div class="manualnavbar" style="text-align: center;">
 <div class="prev" style="text-align: left; float: left;"><a href="evperiodic.set.html">EvPeriodic::set</a></div>
 <div class="next" style="text-align: right; float: right;"><a href="evprepare.construct.html">EvPrepare::__construct</a></div>
 <div class="up"><a href="book.ev.html">Ev</a></div>
 <div class="home"><a href="index.html">PHP Manual</a></div>
</div></body></html>
